package leecode

import "strconv"

type Codec struct {
	hashMap map[string]string
}

func Constructor535() Codec {
	hashMap := make(map[string]string)
	return Codec{hashMap}
}

// 加密
func (this *Codec) encode(longUrl string) string {
	code := strconv.Itoa(len(this.hashMap) + 1)
	this.hashMap[code] = longUrl
	return code
}

// 解密
func (this *Codec) decode(shortUrl string) string {
	//通过shortUrl , 拿到longUrl
	return this.hashMap[shortUrl]
}
